]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
unlockDialog: Toggle between clock and auth prompt
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Fri, 29 Nov 2019 17:37:10 +0000 (14:37 -0300)
committerFlorian Müllner <florian.muellner@gmail.com>
Mon, 10 Feb 2020 22:30:52 +0000 (22:30 +0000)
Toggle between them when (1) tapping anythere on the screen, and
(2) pressing any key.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/872

js/ui/unlockDialog.js

index 94752aaf08315df7d1b226a51f3d9e9895ae92db..5d693335180df53d7a6dc05f60c653b8d7df511d 100644 (file)
@@ -16,6 +16,8 @@ const IDLE_TIMEOUT = 2 * 60;
 
 const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
 
+const CROSSFADE_TIME = 300;
+
 const BLUR_BRIGHTNESS = 0.55;
 const BLUR_RADIUS = 200;
 
@@ -400,10 +402,17 @@ var UnlockDialog = GObject.registerClass({
             accessible_role: Atk.Role.WINDOW,
             style_class: 'login-dialog',
             visible: false,
+            reactive: true,
         });
 
         parentActor.add_child(this);
 
+        this._activePage = null;
+
+        let tapAction = new Clutter.TapAction();
+        tapAction.connect('tap', this._showPrompt.bind(this));
+        this.add_action(tapAction);
+
         // Background
         this._backgroundGroup = new Clutter.Actor();
         this.add_child(this._backgroundGroup);
@@ -426,6 +435,7 @@ var UnlockDialog = GObject.registerClass({
 
         this._clock = new Clock();
         stack.add_child(this._clock);
+        this._showClock();
 
         this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(), AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
         this._authPrompt.connect('failed', this._fail.bind(this));
@@ -476,6 +486,21 @@ var UnlockDialog = GObject.registerClass({
         this.connect('destroy', this._onDestroy.bind(this));
     }
 
+    vfunc_key_press_event(keyEvent) {
+        if (this._activePage === this._promptBox ||
+            (this._promptBox && this._promptBox.visible))
+            return Clutter.EVENT_PROPAGATE;
+
+        let unichar = keyEvent.unicode_value;
+
+        this._showPrompt();
+
+        if (GLib.unichar_isgraph(unichar))
+            this.addCharacter(unichar);
+
+        return Clutter.EVENT_PROPAGATE;
+    }
+
     _createBackground(monitorIndex) {
         let monitor = Main.layoutManager.monitors[monitorIndex];
         let widget = new St.Widget({
@@ -523,6 +548,48 @@ var UnlockDialog = GObject.registerClass({
         }
     }
 
+    _showClock() {
+        if (this._activePage === this._clock)
+            return;
+
+        this._activePage = this._clock;
+        this._clock.show();
+
+        this._promptBox.ease({
+            opacity: 0,
+            duration: CROSSFADE_TIME,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+            onComplete: () => this._promptBox.hide(),
+        });
+
+        this._clock.ease({
+            opacity: 255,
+            duration: CROSSFADE_TIME,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+        });
+    }
+
+    _showPrompt() {
+        if (this._activePage === this._promptBox)
+            return;
+
+        this._activePage = this._promptBox;
+        this._promptBox.show();
+
+        this._clock.ease({
+            opacity: 0,
+            duration: CROSSFADE_TIME,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+            onComplete: () => this._clock.hide(),
+        });
+
+        this._promptBox.ease({
+            opacity: 255,
+            duration: CROSSFADE_TIME,
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+        });
+    }
+
     _fail() {
         this.emit('failed');
     }
@@ -569,6 +636,7 @@ var UnlockDialog = GObject.registerClass({
     }
 
     addCharacter(unichar) {
+        this._showPrompt();
         this._authPrompt.addCharacter(unichar);
     }